<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"vchao.top","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="## 开始 安卓开发中，有时候会遇到到处文件的需求，尤其是平板上的开发，这个需求更为普遍，本文记录导出excel，txt文件的方法，并提供工具类，抛砖引玉，让大家遇到类似需求的时候，处理起来更为顺手。导出工具类。使用方法 思路导出txt文件需求比较普遍。直接进行文件读写即可。导出excel文件往往需要借助第三方jar包的帮助完成。（下载链接后续补上） 实现需求中，往往遇到的情况是将一个列表的数据">
<meta property="og:type" content="article">
<meta property="og:title" content="安卓导出Excel，txt文件工具类">
<meta property="og:url" content="http://vchao.top/2021/08/25/%E5%AE%89%E5%8D%93%E5%AF%BC%E5%87%BAExcel%EF%BC%8Ctxt%E6%96%87%E4%BB%B6%E5%B7%A5%E5%85%B7%E7%B1%BB/index.html">
<meta property="og:site_name" content="乘风破浪">
<meta property="og:description" content="## 开始 安卓开发中，有时候会遇到到处文件的需求，尤其是平板上的开发，这个需求更为普遍，本文记录导出excel，txt文件的方法，并提供工具类，抛砖引玉，让大家遇到类似需求的时候，处理起来更为顺手。导出工具类。使用方法 思路导出txt文件需求比较普遍。直接进行文件读写即可。导出excel文件往往需要借助第三方jar包的帮助完成。（下载链接后续补上） 实现需求中，往往遇到的情况是将一个列表的数据">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-08-25T14:42:51.167Z">
<meta property="article:modified_time" content="2021-08-25T14:37:20.801Z">
<meta property="article:author" content="vchao">
<meta property="article:tag" content="Android">
<meta property="article:tag" content="excel">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://vchao.top/2021/08/25/%E5%AE%89%E5%8D%93%E5%AF%BC%E5%87%BAExcel%EF%BC%8Ctxt%E6%96%87%E4%BB%B6%E5%B7%A5%E5%85%B7%E7%B1%BB/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>安卓导出Excel，txt文件工具类 | 乘风破浪</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">乘风破浪</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://vchao.top/2021/08/25/%E5%AE%89%E5%8D%93%E5%AF%BC%E5%87%BAExcel%EF%BC%8Ctxt%E6%96%87%E4%BB%B6%E5%B7%A5%E5%85%B7%E7%B1%BB/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="vchao">
      <meta itemprop="description" content="怀揣好奇，梦想改变世界的菜鸟极客">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="乘风破浪">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          安卓导出Excel，txt文件工具类
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-08-25 22:42:51 / 修改时间：22:37:20" itemprop="dateCreated datePublished" datetime="2021-08-25T22:42:51+08:00">2021-08-25</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>﻿## 开始</p>
<p>安卓开发中，有时候会遇到到处文件的需求，尤其是平板上的开发，这个需求更为普遍，本文记录导出excel，txt文件的方法，并提供工具类，抛砖引玉，让大家遇到类似需求的时候，处理起来更为顺手。<br>导出工具类。使用方法</p>
<h2 id="思路"><a href="#思路" class="headerlink" title="思路"></a>思路</h2><p>导出txt文件需求比较普遍。直接进行文件读写即可。导出excel文件往往需要借助第三方jar包的帮助完成。（下载链接后续补上）</p>
<h2 id="实现"><a href="#实现" class="headerlink" title="实现"></a>实现</h2><p>需求中，往往遇到的情况是将一个列表的数据进行导出。因此本文处理的也是这种情况，直接传入列表即可。</p>
<p>工具类调用方法：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ExportUtil.writeExcel(DataExportActivity.<span class="keyword">this</span>, actionLogModels, <span class="string">&quot;excel&quot;</span>);</span><br></pre></td></tr></table></figure>
<p>本文以行为日志的记录为例，具体bean类型如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">  <span class="keyword">public</span> <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">ActionLogModel</span> </span>&#123;</span><br><span class="line">      <span class="keyword">private</span> <span class="keyword">int</span> id;</span><br><span class="line">      <span class="keyword">private</span> String action_date;</span><br><span class="line">      <span class="keyword">private</span> String action_time;</span><br><span class="line">      <span class="keyword">private</span> String user_name;</span><br><span class="line">      <span class="keyword">private</span> String user_action;</span><br><span class="line"><span class="comment">// ... 省略 构造函数</span></span><br><span class="line"> 		<span class="comment">// ... 省略 get set 方法</span></span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>文件导出工具类</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 导出工具类</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ExportUtil</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 内存地址</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> String root = Environment.getExternalStorageDirectory().getPath();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> String saveDir =root+<span class="string">&quot;/export&quot;</span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">writeExcel</span><span class="params">(Context context, List&lt;ActionLogModel&gt; actionLogModels, String fileName)</span> <span class="keyword">throws</span> Exception </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) &amp;&amp; getAvailableStorage() &gt; <span class="number">1000000</span>) &#123;</span><br><span class="line">            ToastUtil.showShort(<span class="string">&quot;SD卡不可用&quot;</span>);</span><br><span class="line">            <span class="keyword">return</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        File file;</span><br><span class="line">        File dir = <span class="keyword">new</span> File(saveDir);</span><br><span class="line">        <span class="keyword">if</span> (!dir.exists()) &#123;</span><br><span class="line">            dir.mkdirs();</span><br><span class="line">        &#125;</span><br><span class="line">        file = <span class="keyword">new</span> File(dir, fileName + <span class="string">&quot;.xls&quot;</span>);</span><br><span class="line">        String[] title = &#123;<span class="string">&quot;日志id&quot;</span>, <span class="string">&quot;日期&quot;</span>, <span class="string">&quot;时间&quot;</span>, <span class="string">&quot;用户&quot;</span>, <span class="string">&quot;操作&quot;</span>&#125;;</span><br><span class="line">        <span class="comment">// 创建Excel工作表</span></span><br><span class="line">        WritableWorkbook wwb;</span><br><span class="line">        OutputStream os = <span class="keyword">new</span> FileOutputStream(file);</span><br><span class="line">        wwb = Workbook.createWorkbook(os);</span><br><span class="line">        <span class="comment">// 添加第一个工作表并设置第一个Sheet的名字</span></span><br><span class="line">        WritableSheet sheet = wwb.createSheet(<span class="string">&quot;用户操作&quot;</span>, <span class="number">0</span>);</span><br><span class="line">        Label label;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; title.length; i++) &#123;</span><br><span class="line">            <span class="comment">// Label(x,y,z) 代表单元格的第x+1列，第y+1行, 内容z</span></span><br><span class="line">            <span class="comment">// 在Label对象的子对象中指明单元格的位置和内容</span></span><br><span class="line">            label = <span class="keyword">new</span> Label(i, <span class="number">0</span>, title[i], getHeader());</span><br><span class="line">            <span class="comment">// 将定义好的单元格添加到工作表中</span></span><br><span class="line">            sheet.addCell(label);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; actionLogModels.size(); i++) &#123;</span><br><span class="line">            ActionLogModel actionLogModel = actionLogModels.get(i);</span><br><span class="line"></span><br><span class="line">            Label id = <span class="keyword">new</span> Label(<span class="number">0</span>, i + <span class="number">1</span>, <span class="string">&quot;&quot;</span> + actionLogModel.getId());</span><br><span class="line">            Label date = <span class="keyword">new</span> Label(<span class="number">1</span>, i + <span class="number">1</span>, actionLogModel.getAction_date());</span><br><span class="line">            Label time = <span class="keyword">new</span> Label(<span class="number">2</span>, i + <span class="number">1</span>, actionLogModel.getAction_time());</span><br><span class="line">            Label user_name = <span class="keyword">new</span> Label(<span class="number">3</span>, i + <span class="number">1</span>, actionLogModel.getUser_name());</span><br><span class="line">            Label user_action = <span class="keyword">new</span> Label(<span class="number">4</span>, i + <span class="number">1</span>, actionLogModel.getUser_action());</span><br><span class="line"></span><br><span class="line">            sheet.addCell(id);</span><br><span class="line">            sheet.addCell(date);</span><br><span class="line">            sheet.addCell(time);</span><br><span class="line">            sheet.addCell(user_name);</span><br><span class="line">            sheet.addCell(user_action);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 写入数据</span></span><br><span class="line">        wwb.write();</span><br><span class="line">        <span class="comment">// 关闭文件</span></span><br><span class="line">        wwb.close();</span><br><span class="line">        ToastUtil.showShort(<span class="string">&quot;写入成功&quot;</span>);</span><br><span class="line">        <span class="keyword">if</span> (file.exists()) &#123;</span><br><span class="line">            LogUtil.e(<span class="string">&quot;文件确实创建了&quot;</span> + file.getAbsolutePath());</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            LogUtil.e(<span class="string">&quot;假的，文件就没有创建&quot;</span> + file.getAbsolutePath());</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> WritableCellFormat <span class="title">getHeader</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        WritableFont font = <span class="keyword">new</span> WritableFont(WritableFont.TIMES, <span class="number">10</span>, WritableFont.BOLD);<span class="comment">// 定义字体</span></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            font.setColour(Colour.BLUE);<span class="comment">// 蓝色字体</span></span><br><span class="line">        &#125; <span class="keyword">catch</span> (WriteException e1) &#123;</span><br><span class="line">            e1.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">        WritableCellFormat format = <span class="keyword">new</span> WritableCellFormat(font);</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            format.setAlignment(jxl.format.Alignment.CENTRE);<span class="comment">// 左右居中</span></span><br><span class="line">            format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);<span class="comment">// 上下居中</span></span><br><span class="line">            <span class="comment">// format.setBorder(Border.ALL, BorderLineStyle.THIN,</span></span><br><span class="line">            <span class="comment">// Colour.BLACK);// 黑色边框</span></span><br><span class="line">            <span class="comment">// format.setBackground(Colour.YELLOW);// 黄色背景</span></span><br><span class="line">        &#125; <span class="keyword">catch</span> (WriteException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> format;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 获取SD可用容量</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">long</span> <span class="title">getAvailableStorage</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        StatFs statFs = <span class="keyword">new</span> StatFs(root);</span><br><span class="line">        <span class="keyword">long</span> blockSize = statFs.getBlockSize();</span><br><span class="line">        <span class="keyword">long</span> availableBlocks = statFs.getAvailableBlocks();</span><br><span class="line">        <span class="keyword">long</span> availableSize = blockSize * availableBlocks;</span><br><span class="line">        <span class="comment">// Formatter.formatFileSize(context, availableSize);</span></span><br><span class="line">        <span class="keyword">return</span> availableSize;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//写入文件保存在根目录下面</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">writeTxtFile</span><span class="params">(Context context, List&lt;ActionLogModel&gt; list, String file_name)</span> </span>&#123;</span><br><span class="line">        File dir = <span class="keyword">new</span> File(saveDir);</span><br><span class="line">        <span class="keyword">if</span> (!dir.exists()) &#123;</span><br><span class="line">            dir.mkdirs();</span><br><span class="line">        &#125;</span><br><span class="line">        File file;</span><br><span class="line"><span class="comment">//        String filename = Environment.getExternalStorageDirectory() + &quot;/&quot; + file_name + &quot;.txt&quot;;</span></span><br><span class="line">        FileOutputStream outputStream;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            file = <span class="keyword">new</span> File(dir, file_name + <span class="string">&quot;.txt&quot;</span>);</span><br><span class="line">            outputStream = <span class="keyword">new</span> FileOutputStream(file);</span><br><span class="line"><span class="comment">//            outputStream = openFileOutput(filename, MODE_PRIVATE);</span></span><br><span class="line">            outputStream.write(<span class="string">&quot;日志id\t日期\t\t时间\t用户\t操作\r\n&quot;</span>.getBytes(<span class="string">&quot;utf-8&quot;</span>));</span><br><span class="line">            <span class="keyword">for</span> (ActionLogModel actionLogModel : list) &#123;</span><br><span class="line">                outputStream.write((actionLogModel.getId() + <span class="string">&quot;\t&quot;</span> + actionLogModel.getAction_date() + <span class="string">&quot;\t&quot;</span> + actionLogModel.getAction_time() + <span class="string">&quot;\t&quot;</span></span><br><span class="line">                        + actionLogModel.getUser_name() + <span class="string">&quot;\t&quot;</span> + actionLogModel.getUser_action() + <span class="string">&quot;\r\n&quot;</span>).getBytes(<span class="string">&quot;utf-8&quot;</span>));</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            LogUtil.e(<span class="string">&quot;path &quot;</span> + file.getAbsolutePath());</span><br><span class="line">            outputStream.close();</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">            LogUtil.e(<span class="string">&quot;异常异常 &quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Android/" rel="tag"># Android</a>
              <a href="/tags/excel/" rel="tag"># excel</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/08/25/%E5%AE%89%E5%8D%93%E5%8F%AF%E4%B8%8A%E4%B8%8B%E6%BB%91%E5%8A%A8%E6%94%B9%E5%8F%98%E6%95%B0%E5%80%BC%E7%9A%84%E6%8A%98%E7%BA%BF%E5%9B%BE%EF%BC%88%E5%9F%BA%E4%BA%8Ehellochart%EF%BC%89/" rel="prev" title="安卓可上下滑动改变数值的折线图（基于hellochart）">
      <i class="fa fa-chevron-left"></i> 安卓可上下滑动改变数值的折线图（基于hellochart）
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/08/25/%E5%AE%89%E5%8D%93%E5%B0%8F%E6%8A%80%E5%B7%A7%EF%BC%9A%E8%BD%AF%E4%BB%B6%E4%B8%AD%E6%98%BE%E7%A4%BA%E7%89%88%E6%9C%AC%E6%89%93%E5%8C%85%E6%97%B6%E9%97%B4/" rel="next" title="安卓小技巧：软件中显示版本打包时间">
      安卓小技巧：软件中显示版本打包时间 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%80%9D%E8%B7%AF"><span class="nav-number">1.</span> <span class="nav-text">思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E7%8E%B0"><span class="nav-number">2.</span> <span class="nav-text">实现</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">vchao</p>
  <div class="site-description" itemprop="description">怀揣好奇，梦想改变世界的菜鸟极客</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">46</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">分类</span>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">27</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">冀ICP备 17022751号-1 </a>
      <img src="https://beian.miit.gov.cn" style="display: inline-block;">
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">vchao</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
